package cn.yr.test.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

	public static void main(String[] args) throws IOException {

		ServerSocket serverSocket = new ServerSocket(2000);


		System.out.println("服务端等待连接");
		Socket accept = serverSocket.accept();

		todo(accept);
	}

	private static void todo(Socket client) throws IOException {
		InputStream inputStream = client.getInputStream();
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
		while (true){
			String s = bufferedReader.readLine();
			System.out.println(s);
		}
	}
}
